/**
 * @file main.c
 * @author hpy (yuan_hp@qq.com)
 * @brief  只作为示例，实际情况不要使用该方法，51上会占用过多ROM资源
 * @version 0.1
 * @date 2025-07-03
 * 
 * @copyright Copyright (c) 2025
 * 
 */
#include "main.h"

MultiTask task1;
MultiTask task2;


void task1Cb(MultiTask* task, void *userData)
{
    P0=0; 
}

void task2Cb(MultiTask* task, void *userData)
{
    P0=1; 
}

#define TIMER_RS  1200000UL
void main() {
    // uint32_t TIMER_RS = 12000000/10;
    P0 = 0;

    MultiTaskStart(&task1, 1, task1Cb, (void *)0);
	MultiTaskStart(&task2, 2, task2Cb, (void *)0);
    
    // 设置定时器0 
    PXY_WR(TIMER_BASE + 0,(TIMER_RS>>16)&0xff );
    PXY_WR(TIMER_BASE + 1,(TIMER_RS>>8)&0xff);
    PXY_WR(TIMER_BASE + 2,TIMER_RS&0xff); 
    // 使能定时器0
    PXY_WR(TIMER_BASE + 3,0x01);
    IE = 0X80 ; //开启全局中断 
    while(1) {
        if(taskTimerFlag) {
            MultiTaskYield() ;
            taskTimerFlag=0;
        }
    }
}